package org.huangrui.controller;

import dev.langchain4j.model.chat.ChatModel;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author hr
 * @Create 2025-11-09 9:36
 * @Description: 知识出处，https://docs.langchain4j.dev/tutorials/model-parameters/
 **/
@RestController
public class ModelParameterController {
    @Resource(name = "qwen")
    private ChatModel chatModelQwen;

    // http://localhost:9004/modelparam/config
    // http://localhost:9004/modelparam/config?prompt=介绍一下三文鱼
    @GetMapping(value = "/modelparam/config")
    public String config(@RequestParam(value = "prompt", defaultValue = "你是谁") String prompt) {
        String result = chatModelQwen.chat(prompt);

        System.out.println("通过langchain4j调用模型返回结果：" + result);

        return result;
    }
}
